package cn.jari.erp.inventory.patches

import com.csicit.ace.api.BatchElementEvent
import cn.jari.erp.inventory.ServicePatchGroup
import com.csicit.ace.patcher.PatchProvider
import com.csicit.ace.utils.AceAppContext
import com.csicit.ace.api.modeler.dto.EntityDefinitionReference
import com.csicit.ace.api.modeler.dto.PropertyDefinitionReference
import com.csicit.ace.api.modeler.enums.CollectionType
import com.csicit.ace.api.modeler.enums.DataType
import com.csicit.ace.api.modeler.event.ModelerBatchEvent
import com.csicit.ace.api.modeler.event.constraint.CreateEntityConstraintEvent
import com.csicit.ace.api.modeler.event.property.CreatePropertyEvent
import java.util.List
import java.util.Map
import java.util.Set
import org.axonframework.eventhandling.gateway.EventGateway
import org.springframework.stereotype.Component

/*
 * 警告：代码由鲲舟平台生成，请勿手动修改。
 * Warn: This class file is generated by JARI-ACE platform, please do not modify manually。
 */

/**
 * inventory-service的0.1.0-SNAPSHOT-2版升级补丁
 *
 * @author JARI-ACE
 */
@Component
@AceAppContext
open class Patch_0_1_0_SNAPSHOT_2(val eventGateway: EventGateway) : PatchProvider {
    override fun getGroup(): Class<*> {
        return ServicePatchGroup::class.java
    }

    override fun getPatchVersion(): Long {
        return 549755813890
    }

    override fun getProductVersion(): String {
        return "0.1.0-SNAPSHOT-2"
    }

    override fun executePatch() {
        doExecuteModelerBatchEvent0()
    }

    fun doExecuteModelerBatchEvent0() {
        val modelerBatchEvent = ArrayList<BatchElementEvent>()
        modelerBatchEvent.add(CreatePropertyEvent.builder()
            .id("8nkFbruJIto")
            .dataVersion(0)
            .entity(EntityDefinitionReference.builder()
                .id("8nkFbruJIsO")
                .releaseSource("8716")
                .sourceId("5uFzovh2zo6")
                .dataVersion(0)
                .name("InventoryItem")
                .caption("存货档案")
                .tableName("iv_inventory_item")
                .build())
            .name("aaaaaaa")
            .columnName("aaaaaaa")
            .caption("aaaaaa")
            .comment("")
            .dataType(DataType.STRING)
            .attachId(null)
            .collectionType(CollectionType.NONE)
            .collectionTableName(null)
            .joinColumnName(null)
            .mapKeyDataType(null)
            .refKeyDataType(null)
            .refKeySize(null)
            .entityPrimaryKeyColumnName(null)
            .mapKeyEnum(null)
            .mapKeyColumnName(null)
            .entityType(null)
            .mappedByProperty(null)
            .enumType(null)
            .cascadeType(setOf())
            .orphanRemoval(null)
            .relationMode(null)
            .orderedCollection(true)
            .orderByDescriptors(listOf())
            .notNull(false)
            .primaryKey(false)
            .attachConfigKey("")
            .numberTemplateName("")
            .size(255)
            .builtIn(false)
            .writeRole(null)
            .readRole(null)
            .defaultValue("")
            .treeDiscriminator(null)
            .appName("jari-erp")
            .appServiceName("inventory-service")
            .datasourceId("8nkFbruJIsS")
            .releaseSource("8716")
            .sourceId("8nkFbruJIto")
            .build())
        modelerBatchEvent.add(CreateEntityConstraintEvent.builder()
            .id("8nkFbruJIsR")
            .dataVersion(0)
            .appName("jari-erp")
            .appServiceName("inventory-service")
            .constraintName("size")
            .entity(EntityDefinitionReference.builder()
                .id("8nkFbruJIsO")
                .releaseSource("8716")
                .sourceId("5uFzovh2zo6")
                .dataVersion(0)
                .name("InventoryItem")
                .caption("存货档案")
                .tableName("iv_inventory_item")
                .build())
            .properties(setOf(PropertyDefinitionReference.builder()
  .id("8nkFbruJIto")
  .releaseSource("8716")
  .sourceId("8nkFbruJIto")
  .name("aaaaaaa")
  .caption("aaaaaa")
  .entity(EntityDefinitionReference.builder()
    .id("8nkFbruJIsO")
    .releaseSource("8716")
    .sourceId("5uFzovh2zo6")
    .dataVersion(0)
    .name("InventoryItem")
    .caption("存货档案")
    .tableName("iv_inventory_item")
    .build())
  .build()))
            .constraintParameters(mapOf("max" to "255"))
            .message(null)
            .payloads(setOf())
            .groups(setOf())
            .releaseSource("8716")
            .sourceId("8nkFbruJIsR")
            .datasourceId("8nkFbruJIsS")
            .build())
        eventGateway.publish(ModelerBatchEvent.builder()
                                          .events(modelerBatchEvent)
                                          .build())
    }

    override fun getPatchSource(): String {
        return "c321"
    }
}

